<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body{
            font-family: cursive;
        }
    </style>
</head>
<body>

<script>
    var p=prompt("请输入金字塔的层数：");
    for(var i=0; i<p ; i++){
        var unm=p - i;
        for(var j=0;j<unm;j++){
            document.write("&nbsp;");
        }
        var m=(i+1)*2-1;
        for(var n=0;n<m;n++){
            document.write("*");
        }
        document.write("<br>");
    }

</script>


</body>
</html>